package zeepos.repository.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.solr.core.SolrTemplate;
import org.springframework.stereotype.Repository;

import zeepos.repository.ImportSolrReposity;

@Repository
public class ImportSolrReposityImpl implements ImportSolrReposity {
	@Autowired
	private SolrTemplate solrTemplate;

	public int importSolr(String solrCollectionName, List result) {
		try {
			solrTemplate.saveBeans(solrCollectionName, result);
			solrTemplate.commit(solrCollectionName);
		} catch (Exception e) {
			return result.size();
		}
		return 0;
	}

}
